import loginService  from "../../service/user/loginService";
const koaRouter = require('koa-router');
const router = koaRouter();
// const addtoken = require('../../config/addtoken');  // 创建 token
// const decodetoken = require('../../config/decodetoken');    // 解密 token

/**
 * 登录
 **/
router.post('/login',async(ctx)=>{
    let result:any=await new loginService().login(ctx.request.body);
    if(result){
        if(result.length>0){
            // let token = addtoken(result[0]);
            // ctx.body ={success:true,datas:result,token};
            ctx.body ={success:true,datas:result};
        }else{
            ctx.body ={success:false,msg:'账号或密码错误！',};
        }
    }else{
        ctx.body ={success:false,msg:"未知错误"};
    }
})

module.exports = router;